{% set pypi_name = 'renderspec' %}
{% set upstream_version = upstream_version('2.1.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

%global oldpython python
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Generate spec files from Jinja2 templates
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        https://files.pythonhosted.org/packages/source/r/{{ pypi_name }}/{{ pypi_name }}-%{version}.tar.gz
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('Jinja2') }}
BuildRequires:  {{ py3('ddt') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('packaging') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('pymod2pkg') }}
BuildRequires:  {{ py3('stestr') }}
BuildArch:      noarch

%description
renderspec is a tool to convert a .spec.j2 Jinja2 template to
a rpm .spec file which is usable for different distributions
and follow their policies and processes.

%package -n {{ py2name(py_versions='py3') }}
Summary:        Generate spec files from Jinja2 templates
Requires:       {{ py3('Jinja2') }}
Requires:       {{ py3('PyYAML') }}
Requires:       {{ py3('packaging') }}
Requires:       {{ py3('pymod2pkg') }}
Requires:       {{ py3('six') }}
Conflicts:      %{oldpython}-renderspec < %{version}

%description -n {{ py2name(py_versions='py3') }}
renderspec is a tool to convert a .spec.j2 Jinja2 template to
a rpm .spec file which is usable for different distributions
and follow their policies and processes.

%package -n {{ py2name() }}-doc
Summary:        Documentation for the renderspec utility
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
Requires:       {{ py2name(py_versions='py3') }} = %{version}

%description -n {{ py2name() }}-doc
Documentation for the renderspec tool which is a tool to convert
a spec.j2 Jinja2 template into a rpm .spec file.

%prep
%autosetup -p 1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc README.rst ChangeLog
%{_bindir}/{{ pypi_name }}
%{python3_sitelib}/{{ pypi_name }}
%{python3_sitelib}/*.egg-info

%files -n {{ py2name() }}-doc
%doc doc/build/html
%license LICENSE

%changelog
